<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>工程合同查看</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../resources/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../resources/css/style.css" media="all">
    <style>
        .details li{width: 50%;float: left;}
        .layui-table thead th{text-align: left;}
        .engineering_c{margin-top: 10px;}
        .engineering_c li{width: 100%;}
        .shenheBtn{float: right; margin-top: 10px;}
        .s_hide{margin-top: 10px;}
        .layui-select-title input{width: 100%;margin-bottom: 10px;margin-top: 10px;}
        .layui-input{width: 100%;}
        .layui-form-pane .layui-form-label{width: 100px;}
        .layui-form-select{width: 100%;}
        ._hide{display: none;}
        .engineering_c .detaL{width: 120px;padding-right: 20px;float: left;}
        .engineering_c .dataR{width: 75%;}
    </style>
</head>
<body>
<button class="layui-btn" onclick="history.back(-1);"><i class="layui-icon"></i></button>
<div class="shenpiSeeS"></div>
<form class="layui-form layui-form-pane shenpiSee" action="" >
    <div class="layui-form-item">
        <label class="layui-form-label">审核</label>
        <div class="layui-input-block">
            <select name="interest" lay-filter="aihao" class="state">
                <option value="0">通过</option>
                <option value="1">不通过</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">审核人</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入审核人" class="layui-input cc_valiperson">
            <input type="hidden" name="cc_valinum" class="cishu"/>
        </div>
    </div>
</form>

<button class="layui-btn shent" lay-filter="shenhe" type="button">审核</button>
<script src="../../../resources/layui/layui.js" charset="utf-8"></script>
<script src="../../../resources/js/style.js"></script>
<script src="../../../resources/js/api.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate','table'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,table=layui.table
            ,laydate = layui.laydate;
        var transmit=new Object();      //接受数据传递  发送ajax需调用

        if(sessionStorage.stear=='detail'){
            $('.shenpiSee').hide();
            $('.shent').hide();
        }else{
            $('.shenpiSee').show();
            $('.shent').show();
        }


        $('.shenpiSee').attr('action',urls+'/api/contract/conVali.do');

            ajaxs('/api/contract/conValiDetails.do','post',{'uuid':sessionStorage.shenpiUID,'p':getCookie('yanzheng')},function
                (datas) {
                console.log(datas)
                transmit=datas;
                if(datas.code=='0'){
                    var data=datas.data[0][0]
                    var gongchenggaikuo='';             //接收字符串拼接
                    if (data.c_type && data.c_type === 1){
                        gongchenggaikuo = data.c_build || '';
                        data.gcfy = data.c_price;
                    }else {
                        for(var i=0;i<datas.data[2].length;i++){
                            gongchenggaikuo+=datas.data[2][i].cc_cname+':'+datas.data[2][i].cc_cnum+datas.data[2][i].cc_cbit+'&nbsp&nbsp&nbsp&nbsp';//字符串拼接  传递数据
                        }
                    }

                    $('.cishu').val(datas.data[3][0].cc_ValiNum);       //接受审核次数
                    switch (datas.data[3][0].cc_result){
                        case 0:
                            datas.data[3][0].cc_result='审核通过';
                            break;
                        case 1:
                            datas.data[3][0].cc_result='审核不通过';
                            break;
                        case -1:
                            datas.data[3][0].cc_result='等待审核';
                            break;
                    }
                    if(!data.gcfy){
                        data.gcfy='';
                    }


                    var gongC='';
                    for(var i=0;i<datas.data[2].length;i++){
                        gongC+=datas.data[2][i].cc_cname+','+datas.data[2][i].cc_cprice+','+datas.data[2][i].cc_cnum+','+datas.data[2][i].cc_cbit+'&nbsp;&nbsp;&nbsp;'
                    }
                    $('.shenpiSeeS').append(' <div class="engineering"><!--工程信息-->\n' +
                        '        <div class="titles">编号:<span>'+data.cc_Code+'</span></div>\n' +
                        '        <div class="details">\n' +
                        '            <ul>\n' +
                        '                <li><span class=\'detaL\'>工程名称：</span><span class="dataR"> '+data.eppName+' </span></li>\n' +
                        '                <li><span class=\'detaL\'>计划开工日期：</span><span class="dataR">'+shijians(data.preStaTime)+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>起止点：</span><span class="dataR">'+data.eppStaEnd+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>计划竣工日期：</span><span class="dataR">'+shijians(data.preEndTime)+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>建设单位(甲方)：</span><span class="dataR">'+data.compJs+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>建设单位项目负责人：</span><span class="dataR">'+data.director+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>建设单位联系方式：</span><span class="dataR">'+data.dmotel+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>委托设计单位：</span><span class="dataR">'+data.compName0+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>施工单位(乙方) ：</span><span class="dataR">'+data.compName1+'</span></li>\n' +

                        '                <li><span class=\'detaL\'>施工单位项目负责人：</span><span class="dataR">'+data.compPerson1+'</span></li>\n' +

                        '                <li><span class=\'detaL\'>施工单位联系方式：</span><span class="dataR">'+data.compTel1+'</span></li>\n' +
                        '            </ul>\n' +
                        '        </div>\n' +
                        '    </div>\n' +
                        '    <div class="engineering_c"><!--工程信息-->\n' +
                        '\n' +
                        '        <div class="details">\n' +
                        '            <ul>\n' +
                        '                <li><span class=\'detaL\'>工程概括(规划位置、主要工程量)：</span><span class="dataR"> '+gongchenggaikuo+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>合同单价：</span><span class="dataR">'+data.cc_Price+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>工程费用：</span><span class="dataR">'+data.gcfy+'</span></li>\n' +

                        '                <li><span class=\'detaL\'>决算方式：</span><span class="dataR">'+data.cc_CostType+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>材料供应：</span><span class="dataR">'+data.cc_Material+'</span></li>\n' +
                        '            </ul>\n' +
                        '        </div>\n' +
                        '    </div>\n' +
                        '    <div class="engineering_c"><!--工程信息-->\n' +
                        '\n' +
                        '        <div class="details">\n' +
                        '            <ul>\n' +
                        '                <li><span class=\'detaL\'>工程质量 ：</span><span class="dataR">'+data.cc_BuildMass+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>安全施工：</span><span class="dataR">'+data.cc_Security+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>文明、环保施工：</span><span class="dataR">'+data.cc_Culture+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>竣工验收：</span><span class="dataR">'+data.cc_FinVe+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>质保期限 ：</span><span class="dataR"> '+data.cc_WarrantyTime+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>其他 ：</span><span class="dataR">'+data.cc_Other+'</span></li>\n' +
                        '            </ul>\n' +
                        '        </div>\n' +
                        '    </div>\n' +
                        '    <div class="engineering" style="margin-top: 10px;"><!--工程信息-->\n' +
                        '\n' +
                        '        <div class="details">\n' +
                        '            <ul>\n' +
                        '                <li><span class=\'detaL\'>建设单位(甲方) ：</span><span class="dataR">'+data.compJs+' </span></li>\n' +
                        '                <li><span class=\'detaL\'>施工单位(乙方) ：</span><span class="dataR">'+data.compName1+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>委托代理人：</span><span class="dataR">'+data.director+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>委托代理人：</span><span class="dataR">'+data.compPerson1+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>日期：</span><span class="dataR">'+shijians(data.preEndTime)+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>日期：</span><span class="dataR">'+shijians(data.preStaTime)+'</span></li>\n' +
                        '                <li><span class=\'detaL\'>审批状态：</span><span class="dataR">'+datas.data[3][0].cc_result+'</span></li>\n' +
                        '                <li class="_hide"><span class=\'detaL\'>审批意见：</span><span class="dataR">'+datas.data[3][0].cc_ValiOpinion+'</span></li>\n' +
                        '            </ul>\n' +
                        '        </div>\n' +
                        '    </div>\n');
                    $('.shenpiSee').append(' <div class="s_hide">\n' +
                        '        <div class="layui-form-item layui-form-text">\n' +
                        '            <label   class="layui-form-label">审核意见</label>\n' +
                        '            <div class="layui-input-block">\n' +
                        '                <textarea placeholder="请输入审核意见" class="layui-textarea"></textarea>\n' +
                        '            </div>\n' +
                        '        </div>\n' +
                        '    </div>' +
                        '')
                    if(sessionStorage.stear=='toExamine'){                 //如果是审批按钮进来的 执行这个
                        $('.s_hide').show();

                    }else{
                        $('.s_hide').hide();
                        $('._hide').show();
                    }

                }else{
                    layer.msg('获取失败 请重新尝试')

                }

            })

        var names=getCookie('yanzheng');
        names=names.split('|')
        //console.log(names)
        $('[name="title"]').val(names[0])

        $('.shent').on('click',function () {
            var cc_valiperson=$('.cc_valiperson').val();        //获取传递值
            if(cc_valiperson.length<=0){
                layer.msg('审核人不能为空');
                return;
            }
            Eject('审核确定','您确定提交审核吗?',function () {
                var cc_result=$('.state').val();            //获取状态值
                var opinion=$('.layui-textarea').val();     //获取审批意见
                    //console.log(transmit)

                var datas=transmit.data[3][0];
                cc_valiperson=$.trim(cc_valiperson);                //去空格

                var shijian=Date.parse(new Date());                 //获取当前时间戳
                shijian=times(shijian);                                //时间戳格式转换
                //console.log(cc_valiperson!='','--------------------')
                if(cc_valiperson!=''){
                    ajaxs('/api/contract/conVali.do','post',{
                        'id':datas.id,'uuid':datas.cc_UUID,'cc_valinum':datas.cc_valinum,'cc_valiopinion':opinion,'cc_result':cc_result,'cc_valiperson':cc_valiperson,'updatetime':shijian,'cc_valinum':$('.cishu').val(),'p':getCookie('yanzheng') },function (data) {
                        //console.log(data)
                        layer.msg(data.msg)
                        setTimeout(function () {
                            $('.layui-layer-shade').hide();
                            $('.layui-layer-dialog').hide();
                            history.back(-1);
                        },1000)
                    })
                }else{

                    $('.layui-layer-shade').hide();
                    $('.layui-layer-dialog').hide();
                }



            })



        })


        //监听工具条
        table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if(layEvent === 'detail'){ //查看
                //do somehing
                //console.log(obj)
                sessionStorage.shenpiUID=obj.data.cc_UUID;
                sessionStorage.stear='detail';                //拼接上detail  跳转页面判断
                window.location.href='./shenpiSee.html';
            }else if( layEvent==='toExamine'){      //审核
                alert('222')
            }
        });




    })

</script>
</body>
</html>